﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;//Please add references
namespace TierApplication
{
    /// <summary>
    /// 类T_MOBILEBIND。
    /// </summary>
    [Serializable]
    public partial class T_MOBILEBIND
    {
        public T_MOBILEBIND()
        { }
        #region Model
        private string _mobilebindid;
        private string _accountid;
        private string _mobile;
        private string _authcode;
        private decimal? _smssendid;
        private string _authresult;
        private DateTime? _createdate;
        /// <summary>
        /// 
        /// </summary>
        public string MOBILEBINDID
        {
            set { _mobilebindid = value; }
            get { return _mobilebindid; }
        }
        /// <summary>
        /// 用户账号
        /// </summary>
        public string ACCOUNTID
        {
            set { _accountid = value; }
            get { return _accountid; }
        }
        /// <summary>
        /// 手机号码
        /// </summary>
        public string MOBILE
        {
            set { _mobile = value; }
            get { return _mobile; }
        }
        /// <summary>
        /// 验证码
        /// </summary>
        public string AUTHCODE
        {
            set { _authcode = value; }
            get { return _authcode; }
        }
        /// <summary>
        /// 短信发送编号
        /// </summary>
        public decimal? SMSSENDID
        {
            set { _smssendid = value; }
            get { return _smssendid; }
        }
        /// <summary>
        /// 验证结果 C_AuthResult
        /// </summary>
        public string AUTHRESULT
        {
            set { _authresult = value; }
            get { return _authresult; }
        }
        /// <summary>
        /// 生成日期
        /// </summary>
        public DateTime? CREATEDATE
        {
            set { _createdate = value; }
            get { return _createdate; }
        }
        #endregion Model


        #region  Method

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public T_MOBILEBIND(string MOBILEBINDID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select MOBILEBINDID,ACCOUNTID,MOBILE,AUTHCODE,SMSSENDID,AUTHRESULT,CREATEDATE ");
            strSql.Append(" FROM [T_MOBILEBIND] ");
            strSql.Append(" where MOBILEBINDID=:MOBILEBINDID ");
            OracleParameter[] parameters = {
					new OracleParameter(":MOBILEBINDID", OracleType.VarChar,50)};
            parameters[0].Value = MOBILEBINDID;

            DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["MOBILEBINDID"] != null && ds.Tables[0].Rows[0]["MOBILEBINDID"].ToString() != "")
                {
                    this.MOBILEBINDID = ds.Tables[0].Rows[0]["MOBILEBINDID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ACCOUNTID"] != null && ds.Tables[0].Rows[0]["ACCOUNTID"].ToString() != "")
                {
                    this.ACCOUNTID = ds.Tables[0].Rows[0]["ACCOUNTID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MOBILE"] != null && ds.Tables[0].Rows[0]["MOBILE"].ToString() != "")
                {
                    this.MOBILE = ds.Tables[0].Rows[0]["MOBILE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["AUTHCODE"] != null && ds.Tables[0].Rows[0]["AUTHCODE"].ToString() != "")
                {
                    this.AUTHCODE = ds.Tables[0].Rows[0]["AUTHCODE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SMSSENDID"] != null && ds.Tables[0].Rows[0]["SMSSENDID"].ToString() != "")
                {
                    this.SMSSENDID = decimal.Parse(ds.Tables[0].Rows[0]["SMSSENDID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AUTHRESULT"] != null && ds.Tables[0].Rows[0]["AUTHRESULT"].ToString() != "")
                {
                    this.AUTHRESULT = ds.Tables[0].Rows[0]["AUTHRESULT"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CREATEDATE"] != null && ds.Tables[0].Rows[0]["CREATEDATE"].ToString() != "")
                {
                    this.CREATEDATE = DateTime.Parse(ds.Tables[0].Rows[0]["CREATEDATE"].ToString());
                }
            }
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string MOBILEBINDID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from [T_MOBILEBIND]");
            strSql.Append(" where MOBILEBINDID=:MOBILEBINDID ");

            OracleParameter[] parameters = {
					new OracleParameter(":MOBILEBINDID", OracleType.VarChar,50)};
            parameters[0].Value = MOBILEBINDID;

            return DbHelperOra.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [T_MOBILEBIND] (");
            strSql.Append("MOBILEBINDID,ACCOUNTID,MOBILE,AUTHCODE,SMSSENDID,AUTHRESULT,CREATEDATE)");
            strSql.Append(" values (");
            strSql.Append(":MOBILEBINDID,:ACCOUNTID,:MOBILE,:AUTHCODE,:SMSSENDID,:AUTHRESULT,:CREATEDATE)");
            OracleParameter[] parameters = {
					new OracleParameter(":MOBILEBINDID", OracleType.VarChar,10),
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,20),
					new OracleParameter(":MOBILE", OracleType.VarChar,11),
					new OracleParameter(":AUTHCODE", OracleType.VarChar,6),
					new OracleParameter(":SMSSENDID", OracleType.Number,12),
					new OracleParameter(":AUTHRESULT", OracleType.VarChar,1),
					new OracleParameter(":CREATEDATE", OracleType.DateTime)};
            parameters[0].Value = MOBILEBINDID;
            parameters[1].Value = ACCOUNTID;
            parameters[2].Value = MOBILE;
            parameters[3].Value = AUTHCODE;
            parameters[4].Value = SMSSENDID;
            parameters[5].Value = AUTHRESULT;
            parameters[6].Value = CREATEDATE;

            DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update [T_MOBILEBIND] set ");
            strSql.Append("ACCOUNTID=:ACCOUNTID,");
            strSql.Append("MOBILE=:MOBILE,");
            strSql.Append("AUTHCODE=:AUTHCODE,");
            strSql.Append("SMSSENDID=:SMSSENDID,");
            strSql.Append("AUTHRESULT=:AUTHRESULT,");
            strSql.Append("CREATEDATE=:CREATEDATE");
            strSql.Append(" where MOBILEBINDID=:MOBILEBINDID ");
            OracleParameter[] parameters = {
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,20),
					new OracleParameter(":MOBILE", OracleType.VarChar,11),
					new OracleParameter(":AUTHCODE", OracleType.VarChar,6),
					new OracleParameter(":SMSSENDID", OracleType.Number,12),
					new OracleParameter(":AUTHRESULT", OracleType.VarChar,1),
					new OracleParameter(":CREATEDATE", OracleType.DateTime),
					new OracleParameter(":MOBILEBINDID", OracleType.VarChar,10)};
            parameters[0].Value = ACCOUNTID;
            parameters[1].Value = MOBILE;
            parameters[2].Value = AUTHCODE;
            parameters[3].Value = SMSSENDID;
            parameters[4].Value = AUTHRESULT;
            parameters[5].Value = CREATEDATE;
            parameters[6].Value = MOBILEBINDID;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string MOBILEBINDID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from [T_MOBILEBIND] ");
            strSql.Append(" where MOBILEBINDID=:MOBILEBINDID ");
            OracleParameter[] parameters = {
					new OracleParameter(":MOBILEBINDID", OracleType.VarChar,50)};
            parameters[0].Value = MOBILEBINDID;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public void GetModel(string MOBILEBINDID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select MOBILEBINDID,ACCOUNTID,MOBILE,AUTHCODE,SMSSENDID,AUTHRESULT,CREATEDATE ");
            strSql.Append(" FROM [T_MOBILEBIND] ");
            strSql.Append(" where MOBILEBINDID=:MOBILEBINDID ");
            OracleParameter[] parameters = {
					new OracleParameter(":MOBILEBINDID", OracleType.VarChar,50)};
            parameters[0].Value = MOBILEBINDID;

            DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["MOBILEBINDID"] != null && ds.Tables[0].Rows[0]["MOBILEBINDID"].ToString() != "")
                {
                    this.MOBILEBINDID = ds.Tables[0].Rows[0]["MOBILEBINDID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ACCOUNTID"] != null && ds.Tables[0].Rows[0]["ACCOUNTID"].ToString() != "")
                {
                    this.ACCOUNTID = ds.Tables[0].Rows[0]["ACCOUNTID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MOBILE"] != null && ds.Tables[0].Rows[0]["MOBILE"].ToString() != "")
                {
                    this.MOBILE = ds.Tables[0].Rows[0]["MOBILE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["AUTHCODE"] != null && ds.Tables[0].Rows[0]["AUTHCODE"].ToString() != "")
                {
                    this.AUTHCODE = ds.Tables[0].Rows[0]["AUTHCODE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SMSSENDID"] != null && ds.Tables[0].Rows[0]["SMSSENDID"].ToString() != "")
                {
                    this.SMSSENDID = decimal.Parse(ds.Tables[0].Rows[0]["SMSSENDID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AUTHRESULT"] != null && ds.Tables[0].Rows[0]["AUTHRESULT"].ToString() != "")
                {
                    this.AUTHRESULT = ds.Tables[0].Rows[0]["AUTHRESULT"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CREATEDATE"] != null && ds.Tables[0].Rows[0]["CREATEDATE"].ToString() != "")
                {
                    this.CREATEDATE = DateTime.Parse(ds.Tables[0].Rows[0]["CREATEDATE"].ToString());
                }
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM [T_MOBILEBIND] ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperOra.Query(strSql.ToString());
        }

        #endregion  Method
    }
}

